﻿<%@ page import="com.tentact.coolmeetingtest.vo.Dept" %>
<%@ page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
		 pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
<script type="text/javascript" src="My97DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" href="styles/common.css" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
	<script type="text/javascript">
		function deleteConfirm(deptno){
			let ret = window.confirm("确定删除吗？");
			if(ret){
				window.location.href = "MainServlet?dest=dept.delete&deptno=" + deptno;
			}
		}
	</script>
</head>
	<body>
	<input type="text" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})">
		<div class="page-content">
			<div class="content-nav">人员管理 > 部门管理</div>
			<form action="MainServlet">
				<input type="hidden" value="dept.add" name="dest">
				<fieldset>
					<legend>添加部门</legend>
					部门名称: <input type="text" name="dept_name" id="departmentname" maxlength="20" />
					<input type="submit" class="clickbutton" value="添加" />
				</fieldset>
			</form>
			<table class="listtable">
				<caption>所有部门:</caption>
				<tr class="listheader">
					<th>部门编号</th>
					<th>部门名称</th>
					<th>操作</th>
				</tr>
					<%
						List<Dept> deptList = (List<Dept>) request.getAttribute("depts");
						for(int i = 0;i < deptList.size();i++){ %>
					<tr>
						<td><%=deptList.get(i).getDeptno()%></td>
						<td><%=deptList.get(i).getDeptName()%></td>
						<td>
							<a class="clickbutton" href="editdept.jsp?deptno=<%=deptList.get(i).getDeptno()%>&dept_name=<%=deptList.get(i).getDeptName()%>">编辑</a>
							<a class="clickbutton" onclick="deleteConfirm(<%=deptList.get(i).getDeptno()%>)">删除</a>
						</td>
					</tr>
						<%
						}
					%>
			</table>
		</div>
	</body>
</html>